package net.schmurgon.gwt.scaffold;

import com.google.gwt.app.place.ProxyListPlace;
import com.google.gwt.text.shared.AbstractRenderer;
import net.schmurgon.gwt.request.ApplicationEntityTypesProcessor;
import net.schmurgon.gwt.request.SeriesRecord;
import net.schmurgon.gwt.request.RunnerRecord;
import net.schmurgon.gwt.request.RunRecord;
import net.schmurgon.gwt.request.CourseRecord;

/**
 * Renders {@link ProxyListPlace}s for display to users.
 */
//TODO i18n
public class ApplicationListPlaceRenderer extends AbstractRenderer<ProxyListPlace> {

	public String render(ProxyListPlace object) {
		return new ApplicationEntityTypesProcessor<String>() {

			@Override
			public void handleSeries(SeriesRecord isNull) {
				setResult("Seriess");
			}
			@Override
			public void handleRunner(RunnerRecord isNull) {
				setResult("Runners");
			}
			@Override
			public void handleRun(RunRecord isNull) {
				setResult("Runs");
			}
			@Override
			public void handleCourse(CourseRecord isNull) {
				setResult("Courses");
			}
		}.process(object.getProxyClass());
	}
}
